/**
 * 
 */
package com.cipe.cmrs.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.cipe.cmrs.model.Donorawardtype;
import com.cipe.cmrs.model.User;
import com.cipe.cmrs.util.DateUtil;
import com.cipe.cmrs.util.UserUtil;
@Service
@Transactional
public class DonorawardtypeService extends BaseService<Donorawardtype> {

	@Autowired
	private UserService	userService;

	public Donorawardtype saveDonorawardtype(Donorawardtype donorawardtype, Integer userId) {
		if (donorawardtype != null) {
			User user = UserUtil.INSTANCE.getCurrentUser();
			Donorawardtype dbDonorawardtype = findById(donorawardtype.getId());
			if (dbDonorawardtype == null) {
				dbDonorawardtype = new Donorawardtype();
				dbDonorawardtype.setCreatedBy(user);
				dbDonorawardtype.setCreationDate(DateUtil.getCurrentDate());
			}
			dbDonorawardtype.setDisplayName(donorawardtype.getDisplayName());
			dbDonorawardtype.setDescription(donorawardtype.getDescription());
			dbDonorawardtype.setDeleted(donorawardtype.getDeleted());
			return merge(dbDonorawardtype);
		}
		return null;
	}
}
